CXX = g++
CXXFLAGS = -Wall -Iinclude -g
LDFLAGS = -llog4cpp -lpthread  # 链接选项

SRC_DIR = src
BUILD_DIR = build
TARGET = $(BUILD_DIR)/app
OBJS = $(BUILD_DIR)/main.o
# # ===== 自动收集源文件 =====
# # 获取src目录下所有.cpp文件[1,5](@ref)
# SRCS := $(wildcard $(SRC_DIR)/*.cpp)  
# # 将.cpp路径转为.o路径（src/main.cpp → build/main.o）
# OBJS := $(patsubst $(SRC_DIR)/%.cpp, $(BUILD_DIR)/%.o, $(SRCS)) 
$(BUILD_DIR)/%.o: $(SRC_DIR)/%.cc
 all: $(TARGET)

# 编译阶段：不链接库
$(BUILD_DIR)/%.o: $(SRC_DIR)/%.cc
	@mkdir -p $(@D)
	$(CXX) -c $< -o $@ $(CXXFLAGS)

# 链接阶段：添加 LDFLAGS
$(TARGET): $(OBJS)
	$(CXX) $^ -o $@ $(LDFLAGS)

clean:
	rm -rf $(BUILD_DIR)

.PHONY: all clean
